<?php
namespace TwHelper;

/**
 * 工具类 filter 过滤器
 */
class Filter
{

    /**
     * 时间戳转显示时间
     *
     * @param timestamp $time            
     * @param string $mark            
     * @param string $status            
     * @return string
     */
    public static function makeDate($time, $mark = '.', $status = true)
    {
        $timeDiff = time() - $time;
        if ($timeDiff <= 0) {
            $timeString = date('Y' . $mark . 'm' . $mark . 'd', $time);
        } elseif ($status && $timeDiff < 60) {
            $timeString = '刚刚';
        } elseif ($status && $timeDiff < 3600) {
            $timeString = floor($timeDiff / 60) . '分钟前';
        } elseif ($status && $timeDiff < 86400) {
            $timeString = floor($timeDiff / 3600) . '小时前';
        } elseif ($status && $timeDiff < 2592000) {
            $timeString = floor($timeDiff / 86400) . '天前';
        } else {
            $timeString = date('Y' . $mark . 'm' . $mark . 'd', $time);
        }
        return $timeString;
    }
}